package com.gongyibao.gbase.config;

import com.cvicse.inforsuitemq.InforsuiteMQConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.core.JmsTemplate;

import javax.jms.ConnectionFactory;

@Configuration
public class InforSuiteMQConfig {

    @Value("${infor.mq.brokerURL:}")
    private String host;

    @Bean
    public ConnectionFactory connectionFactory() {
        InforsuiteMQConnectionFactory connectionFactory = new InforsuiteMQConnectionFactory();
        connectionFactory.setBrokerURL(host);
        //connectionFactory.setUserName(username);
       /* connectionFactory.setChannel("CHANNEL");
        connectionFactory.setQueueManager("QUEUE_MANAGER");
        connectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
        connectionFactory.setCCSID(1208);
        connectionFactory.setChannel("SYSTEM.ADMIN.SVRCONN");
        connectionFactory.setAppName("APP_NAME");
        connectionFactory.setUserID(username);*/
        //connectionFactory.setPassword(password);
        return connectionFactory;
    }

    @Bean
    public JmsTemplate jmsTemplate() {
        JmsTemplate jmsTemplate = new JmsTemplate();
        jmsTemplate.setConnectionFactory(connectionFactory());
        jmsTemplate.setDefaultDestinationName("QUEUE_NAME");
        return jmsTemplate;
    }
}
